export default function useSetInterval(): {
	start: (fn: () => void, delay?: number, immediately?: boolean, ...args: any[]) => void;
	clear: () => void;
} {
	let timer: number;
	const clear = (): void => {
		clearInterval(timer);
	};
	const start = (fn: () => void, delay?: number, immediately: boolean = false, ...args: any[]) => {
		clear();
		if (immediately) {
			fn();
		}
		timer = setInterval(fn, delay, ...args);
	};

	return {
		start,
		clear
	};
}
